package com.weibo.net;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public class AccessTokenHeader extends HttpHeaderFactory
{
  public void addAdditionalParams(WeiboParameters paramWeiboParameters1, WeiboParameters paramWeiboParameters2)
  {
  }

  public String generateSignature(String paramString, Token paramToken)
    throws WeiboException
  {
    ((byte[])null);
    try
    {
      Mac localMac = Mac.getInstance("HmacSHA1");
      if (paramToken.getSecretKeySpec() == null)
        paramToken.setSecretKeySpec(new SecretKeySpec(encode(Weibo.APP_SECRET) + "&" + encode(paramToken.getSecret()).getBytes(), "HmacSHA1"));
      localMac.init(paramToken.getSecretKeySpec());
      byte[] arrayOfByte = localMac.doFinal(paramString.getBytes());
      return String.valueOf(Utility.base64Encode(arrayOfByte));
    }
    catch (InvalidKeyException localInvalidKeyException)
    {
      throw new WeiboException(localInvalidKeyException);
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
      throw new WeiboException(localNoSuchAlgorithmException);
    }
  }

  public WeiboParameters generateSignatureList(WeiboParameters paramWeiboParameters)
  {
    Object localObject;
    if ((paramWeiboParameters == null) || (paramWeiboParameters.size() == 0))
      localObject = null;
    while (true)
    {
      return localObject;
      WeiboParameters localWeiboParameters = new WeiboParameters();
      localWeiboParameters.add("oauth_consumer_key", paramWeiboParameters.getValue("oauth_consumer_key"));
      localWeiboParameters.add("oauth_nonce", paramWeiboParameters.getValue("oauth_nonce"));
      localWeiboParameters.add("oauth_signature_method", paramWeiboParameters.getValue("oauth_signature_method"));
      localWeiboParameters.add("oauth_timestamp", paramWeiboParameters.getValue("oauth_timestamp"));
      localWeiboParameters.add("oauth_token", paramWeiboParameters.getValue("oauth_token"));
      localWeiboParameters.add("oauth_verifier", paramWeiboParameters.getValue("oauth_verifier"));
      localWeiboParameters.add("oauth_version", paramWeiboParameters.getValue("oauth_version"));
      localWeiboParameters.add("source", paramWeiboParameters.getValue("source"));
      localObject = localWeiboParameters;
    }
  }
}